package com.wangyadong.hobby.schedule.jobtask.java8;

import com.google.common.base.Function;
import com.wangyadong.hobby.front.model.MyFirstLifeCycle;
import com.wangyadong.hobby.front.model.WemailRecord;
import com.wangyadong.hobby.front.model.WuserInfo;

import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class LambadDemo {

    public static void main(String[] args) {

        Function<String, Integer> ftFunction = (s) -> s.length();
        Integer integer = ftFunction.apply("3423");
        System.out.println(integer);

        Predicate<WuserInfo> predicate = (wuserInfo) -> wuserInfo.getEmai().equals("222");
        boolean test = predicate.test(new WuserInfo());
        System.out.println(test);

        useConsumer(String::length, "123123");
        pythagoraTheorem();
    }


    public static <T> void useConsumer(Consumer<T> tConsumer, T t) {
        tConsumer.accept(t);
    }

    public static void pythagoraTheorem() {
        int a = 9;
        IntStream.rangeClosed(0, 100)
                .filter(b -> Math.sqrt(a * a + b * b) % 1 == 0)
                .boxed()
                .map(b -> new int[]{a, b, (int) Math.sqrt(a * a + b * b)})
                .collect(Collectors.toList())
                .forEach(i -> System.out.println(" 勾=》" + i[0] + "股==》" + i[1] + " 谖==》" + i[2]));

        double sqrt = Math.sqrt(11 * 11 + 9 * 9);
        System.out.println(sqrt + "-->" + sqrt % 1);
    }


    public static void streamOf(){
        WuserInfo wuserInfo = new WuserInfo();
        wuserInfo.setId("11");
        wuserInfo.setUserName("王亚东");
        MyFirstLifeCycle cycle=new MyFirstLifeCycle();
        cycle.setId("2222");
        Stream  stream = Stream.of(cycle, wuserInfo);
//stream.filter(o->o.getId().e)
    }
}
